/*
 * CS_REQ_MY_STATE.cpp
 *
 *  Created on: 2013. 11. 1.
 *      Author: jjaehuny
 */


#include "../../Command.h"

#include "../../User.h"
#include "../../NLogic/Space.h"
#include "../../NLogic/Party.h"

namespace ProjectZ { namespace NCommand {

void Command::CS_REQ_MY_STATE(User * pUser, ::Network::Packet * pPacket)
{
	/*
	 *
	CS_REQ_MY_STATE						0x0950
	{
		u32 u32partyseq;				/// 파티 시퀀스
	}

	SC_REQ_MY_STATE					0x0951
	{
		s16 s16ack;
		s32 s32party_state; 			///
		u8	u8my_state;
	}
	 */

	PREPARE_PACKET;

	NLogic::Party * pParty = pUser->GetParty();
	if (NULL == pParty)
	{

		//DEBUGLOG("CS_REQ_MY_STATE PARTY IS NULL GID : %d", pUser->GetUserSeq());
		DEBUGLOG("CS_REQ_MY_STATE PARTY IS NOT NULL GID : %d USERSTATE : %d", pUser->GetUserSeq(), pUser->GetEnumState());

		::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
		* pAck << static_cast<int16_t>(ACK_OK);
		* pAck << static_cast<int32_t>(0);
		* pAck << static_cast<uint8_t>(pUser->GetEnumState());
		pAck->MakePacket(CMD_SC_REQ_MY_STATE);
		pUser->Send(pAck);
		return;
	}

	DEBUGLOG("CS_REQ_MY_STATE PARTY IS NOT NULL GID : %d PARTYSTATE : %d USERSTATE : %d", pUser->GetUserSeq(), pParty->GetState(), pUser->GetEnumState());

	::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
	* pAck << static_cast<int16_t>(ACK_OK);
	* pAck << static_cast<int32_t>(pParty->GetState());
	* pAck << static_cast<uint8_t>(pUser->GetEnumState());
	pAck->MakePacket(CMD_SC_REQ_MY_STATE);
	pUser->Send(pAck);
}

} /*NCommand*/ } /*ProjectZ*/

